package util;

public class ModInt {

	static public String convertToString(int toConvert, int numBits) {
		String ret = "";
		ret = Integer.toString(toConvert,2);
		//Make value the given number of bits (chars) long
		if( ret.length() > numBits) throw new RuntimeException("Trying to convert number that is too large." +
				" Number of bits allowed: "+numBits+", Number of bits given: "+ret.length());
		while( ret.length() < numBits )
			ret = "0"+ret;		
		return ret;
	}
	
	static public String flipBits(String s) {
		String ret = "";
		for( int i = 0; i < s.length(); i++ )
			ret += (s.charAt(i) == '0') ? "1" : "0";
		return ret;
	}
}
